/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.Arrays;
import java.util.Random;

/**
 * <p>Project: jse2302 - Arr3
 * <p>Powered by webrx On 2023-06-14 09:16:17
 * <p>Created by IntelliJ IDEA
 *
 * @author  webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Arr3 {
    public static void main(String[] args) {
        var ns = new String[]{"李四", "张三丰", "赵六"};
        String[] ns2 = {"李四", "张三丰", "赵六"};
        ns2[2] = "赵丽";
        Random rand = new Random();
        int index = rand.nextInt(ns2.length);
        System.out.println(ns2[index]);

        //java.util.Arrays
        String sss = Arrays.toString(ns2);
        System.out.println(sss);
        System.out.println("-------");
        for (int i = 0; i < ns2.length; i++) {
            // 2 1 0
            System.out.printf("ns2[%d]=%s%n", ns2.length-i-1, ns2[ns2.length-i-1]);
            //0 - 2
            System.out.println(ns2[i]);
        }
        System.out.println("----");
        for(int i=ns2.length-1;i>=0;i--){
            System.out.println(ns2[i]);
        }

        System.out.println("----==============");
        //for 增强语句 foreach forof forin
        for(var s : ns){
            System.out.println(s);
        }


    }
}
